﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Microsoft.Windows.Controls">

    <DataTemplate x:Key="DefaultWatermarkTemplate">
        <ContentControl Content="{Binding}" Foreground="Gray" Focusable="False" />
    </DataTemplate>
    
    <!-- =============================================================================== -->
    <!-- DateTimeUpDown                                                                  -->
    <!-- =============================================================================== -->

    <Style TargetType="{x:Type local:DateTimeUpDown}">
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
        <Setter Property="HorizontalContentAlignment" Value="Right" />
        <Setter Property="TextAlignment" Value="Right" />
        <Setter Property="WatermarkTemplate" Value="{StaticResource DefaultWatermarkTemplate}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DateTimeUpDown}">
                    <local:ButtonSpinner x:Name="Spinner" IsTabStop="False" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}"
                                         AllowSpin="{TemplateBinding AllowSpin}" ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}">
                        <local:WatermarkTextBox x:Name="TextBox" BorderThickness="0" 
                                                Background="Transparent"
                                                ContextMenu="{TemplateBinding ContextMenu}"
                                                FontFamily="{TemplateBinding FontFamily}" 
                                                FontSize="{TemplateBinding FontSize}" 
                                                FontStretch="{TemplateBinding FontStretch}"
                                                FontStyle="{TemplateBinding FontStyle}" 
                                                FontWeight="{TemplateBinding FontWeight}" 
                                                Foreground="{TemplateBinding Foreground}" 
                                                HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"
                                                MinWidth="20" AcceptsReturn="False" 
                                                Padding="0"
                                                TextAlignment="{TemplateBinding TextAlignment}"
                                                TextWrapping="NoWrap" 
                                                TabIndex="{TemplateBinding TabIndex}"
                                                Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}"
                                                Watermark="{TemplateBinding Watermark}"
                                                WatermarkTemplate="{TemplateBinding WatermarkTemplate}"/>
                    </local:ButtonSpinner>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>